<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image Preview with jQuery</title>
<meta name="description" content="Easiest jQuery Tooltip Ever">
<script src="../common/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="assets/main.js" type="text/javascript"></script>
</meta>
<?php
$data = array();
$obj1 = new stdClass();
$obj1->id = 1;
$obj1->path = 'assets/1.jpg';
$obj1->path_thum = 'assets/1s.jpg';
$obj1->value = '10.00';
$obj1->intro = '111111111';
$obj2 = new stdClass();
$obj2->id = 2;
$obj2->path = 'assets/2.jpg';
$obj2->path_thum = 'assets/2s.jpg';
$obj2->value = '20.00';
$obj2->intro = '22222222';
$obj3 = new stdClass();
$obj3->id = 3;
$obj3->path = 'assets/3.jpg';
$obj3->path_thum = 'assets/3s.jpg';
$obj3->value = '30.00';
$obj3->intro = '33333333333';
$obj4 = new stdClass();
$obj4->id = 4;
$obj4->path = 'assets/4.jpg';
$obj4->path_thum = 'assets/4s.jpg';
$obj4->value = '40.00';
$obj4->intro = '444444444444';

$data = array($obj1, $obj2, $obj3, $obj4);
?>

<style>
body {
  margin:0;
  padding:40px;
  background:#fff;
  font:80% Arial, Helvetica, sans-serif;
  color:#555;
  line-height:180%;
}

img{border:none;}
ul,li{
  margin: 0;
  padding: 0;
}
li{
  list-style: none;
  float: left;
  display: inline;
  margin-right: 10px;
}

#preview{
  position: absolute;
  border: 2px solid #454545;
  background: #1b1b1b;
  padding: 0 8px 8px 8px;
  display: none;
  color: #fff;
  }

/*  */
</style>

<script>
$(document).ready(function(){
	var _data = JSON.parse('<?php echo addslashes(json_encode($data)); ?>');
	var div = document.getElementById('show');
	
	var ul = document.createElement('ul');
	ul.id = 'ul_1';
	for (var i = 0, il = _data.length; i < il; i++) {
	  var obj = _data[i];
	  var li = document.createElement('li');
	  var img = document.createElement('img');
	  img.src = obj.path_thum;
	  img.style.cursor = 'pointer';
	  img.href = obj.path;
	  img.title = obj.intro;
	  img.value = obj.value;
	  li.appendChild(img);
	  ul.appendChild(li);
	}
	div.appendChild(ul);

  var div1 = document.getElementById('show1');
  
  var ul = document.createElement('ul');
  ul.id = 'ul_2';
  for (var j = 0, jl = _data.length; j < jl; j++) {
    var obj = _data[j];
    var li = document.createElement('li');
    var img = document.createElement('img');
    img.src = obj.path_thum;
    img.style.cursor = 'pointer';
    img._j = j;
    img.onclick = function() { alert(this._j); };
    img.href = obj.path;
    img.title = obj.intro;
    img.value = obj.value;
    li.appendChild(img);
    ul.appendChild(li);
  }
  div1.appendChild(ul);

  $('#ul_1 li img').imageView({
    width: 440,
    height: 260,
    caption_height: 30,
    xOffset: 10,
    yOffset: 30
  });
  $('#ul_2 li img').imageView({
    width: 200,
    height: 60,
    caption_height: 30,
    xOffset: 10,
    yOffset: 30
  });
});
</script>
</head>
<body>

  <h1>Easy Image Preview with jQuery</h1>

  <h2>Image gallery (with caption)</h2>
<div id="show" height="300px" width="500px"></div>
<div id="show1" height="300px" width="500px"></div>
<!--  <ul>-->
<!--    <li><a href="assets/1.jpg" class="preview" title="Lake and a mountain"><img src="assets/1s.jpg" alt="gallery thumbnail" /></a></li>-->
<!--    <li><a href="assets/2.jpg" class="preview" title="Fly fishing"><img src="assets/2s.jpg" alt="gallery thumbnail" /></a></li>-->
<!--    <li><a href="assets/3.jpg" class="preview" title="Autumn"><img src="assets/3s.jpg" alt="gallery thumbnail" /></a></li>-->
<!--    <li><a href="assets/4.jpg" onclick="alert('x'); return false;" class="preview" title="Skiing on a mountain" value="50.00"><img src="assets/4s.jpg" alt="gallery thumbnail" /></a></li>-->
<!--  </ul>-->

</body>
</html>
